#!/bin/bash

function my_realpath() {
    if [ $# -lt 1 ];then
        echo `pwd`
        return
    fi 

    local path=$1
    local result=
    if [[ $OSTYPE == darwin* ]];then ## stupid mac
        if [ -L "$path" ];then # if it's a link
            readlink $path
        else
            local path=$path;
            if [[ $path == /* ]];then # an absolute path start with /, but it may contains ./ or ../
                local dir=$(dirname $path)
                local base=$(basename $path)
                cd $dir;echo $PWD/$base;cd - 2>&1 1>/dev/null
            else
                # relative dir means successive ./ or ../
                local relative_dir=$(echo "$path" | egrep -o "^(\.+\/?)+") 
                local name=
                eval name=\${1##$relative_dir}
                if [ ! -z $relative_dir ];then
                    cd $relative_dir 2>&1 1>/dev/null
                fi
                echo "$PWD/$name"
            fi
        fi
    else
        result=$(readlink -f ${path})
        echo $result
    fi
}

REALPATH=my_realpath

FILE_PATH=$(dirname $($REALPATH "${BASH_SOURCE[0]}"))

    python $FILE_PATH/teleservice.py $@
